programming4us
           
 
 
SQL Server

Migrating Databases and Data to SQL Azure (part 3) - Reviewing the Generated Script

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
12/26/2010 4:55:34 PM
1.5. Reviewing the Generated Script

Open the file you created, and let's take a quick look at the generated T-SQL. The following snippet from what you see shows the creation of three tables and three stored procedures, and a few INSERT statements that add rows of data to some of the tables. Except for the things you told the script-generation wizard to ignore, the following T-SQL looks like all other object creation T-SQL you typically deal with on a daily basis:

/****** Object:  Table [dbo].[Users]    Script Date: 03/31/2010 23:39:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Users](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NULL,
[NTUserName] [nvarchar](128) NULL,
[Domain] [nvarchar](50) NOT NULL,
[Intro] [nvarchar](100) NULL,
[Title] [nvarchar](50) NOT NULL,
[State] [nvarchar](10) NOT NULL,
[Country] [nvarchar](100) NULL,
[PWD] [varbinary](100) NULL,
[rowguid] [uniqueidentifier] DEFAULT NEWSEQUENTIALID()
PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO

SET IDENTITY_INSERT [dbo].[Users] ON
INSERT [dbo].[Users] ([ID], [Name], [NTUserName], [Domain], [Intro], [Title],
[State], [Country], [PWD])
VALUES (1, N'Herve Roggero', N'hroggero', N'PYNLOGIC',
N'Enterprise and Azure Architect; Speaker. Expert knowledge in C#. Prev. mgmt exp.',
N'Azure Architect', N'FL', N'US',
0xE8F97FBA9104D1EA5047948E6DFB67FACD9F5B73)

INSERT [dbo].[Users] ([ID], [Name], [NTUserName], [Domain], [Intro], [Title],
[State], [Country], [PWD])
VALUES (2, N'Jim Mullis', N'jmullis', N'PYNLOGIC',
N'Expert in software development. C++; Oracle; SQL Server DBA', N'', N'FL', N'US', 0xE8F97FBA9104D1EA5047948E6DFB67FACD9F5B73)

INSERT [dbo].[Users] ([ID], [Name], [NTUserName], [Domain], [Intro], [Title],



[State], [Country], [PWD])
VALUES (3, N'Scott Klein', N'sklein', N'',
N'Expert in software development. MVP SQL Server. Author. Speaker.',
N'Architect', N'FL', N'US', 0xE8F97FBA9104D1EA5047948E6DFB67FACD9F5B73)
SET IDENTITY_INSERT [dbo].[Users] OFF

/****** Object: StoredProcedure [dbo].[proc_CreateProfile]
Script Date: 03/31/2010 23:39:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[proc_CreateProfile]
@uid [nvarchar](50),
@pwd [nvarchar](50),
@name [nvarchar](50),
@title [nvarchar](50),
@country [nvarchar](50),
@state [nvarchar](20),
@rowguid uniqueidentifier
WITH RECOMPILE, ENCRYPTION
AS
DECLARE @password varbinary(100)
SET @password = HASHBYTES('sha1', @pwd)

-- Make sure the UID is not already taken...
IF (Exists(SELECT TOP 1 * FROM Users WHERE NTUserName = @uid))
BEGIN
RAISERROR(N'0x001 - User ID already in use', 16, 1)
END
ELSE
BEGIN
INSERT INTO Users
(Name, NTUserName, Domain, Intro, Title, State, Country, PWD, rowguid)
VALUES
(@name, @uid, '', '', @title, @state, @country, @password, @rowguid)
END
GO

Notice that the script enables several options, such as ANSI_NULL and ANSI_PADDING. Then, the script creates the Users table. This table has an IDENTITY column as well as a rowguid column that uses the uniqueidentifier database. The rowguid column also has a default on it, which uses the NEWSEQUENTIALID() function to automatically generate new GUIDs. This table is created on the PRIMARY file group, followed by the setting of several table options via the WITH clause.

Further down in the script, several stored procedures are created, one of which is shown in the preceding code snippet. proc_CreateProfile is a standard stored procedure that accepts several input parameters and uses the WITH option to specify procedure options: in this case, RECOMPILE (to indicate that the database engine doesn't need to cache a plan for this procedure and to compile the procedure at runtime) and ENCRYPTION (indicating that SQL Server converts the text of this stored procedure to an obfuscated format).

Other -----------------
- SQL Server 2008 : SQL Server Service Broker - Understanding Distributed Messaging
- SQL Server 2008 : Full-Text Search Troubleshooting
- SQL Azure : Security - Access Control
- SQL Server 2008 : Full-Text Searches (part 3) - Stop Lists
- SQL Server 2008 : Full-Text Searches (part 2)
- SQL Server 2008 : Full-Text Searches (part 1) - Search Phrase
- SQL Azure : Securing Your Data (part 3) - Certificates
- SQL Azure : Securing Your Data (part 2) - Hashing
- SQL Azure : Securing Your Data (part 1) - Encryption
- SQL Azure : Security - Overview
- Setting Up a Full-Text Index (part 4) - Using the Full-Text Indexing Wizard to Build Full-Text Indexes and Catalogs
- Setting Up a Full-Text Index (part 3) - Diagnostics
- Setting Up a Full-Text Index (part 2) - Full-Text Indexing of BLOBs and XML
- Setting Up a Full-Text Index (part 1) - Using T-SQL Commands to Build Full-Text Indexes and Catalogs
- Implementing SQL Server 2008 Full-Text Catalogs
- How SQL Server FTS Works
- SQL Azure : Connecting to a SQL Azure Database (part 2) - Connecting from the Entity Framework
- SQL Azure : Connecting to a SQL Azure Database (part 1) - Connecting Using ADO.NET
- SQL Azure : Creating Databases, Logins, and Users (part 2)
- SQL Azure : Creating Databases, Logins, and Users (part 1)
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us